package myTeam.timeShop.bean;

// Generated 2016-3-28 15:20:15 by Hibernate Tools 3.2.2.GA


import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.NamedQueries;
import org.hibernate.annotations.NamedQuery;

import com.alibaba.fastjson.annotation.JSONField;
@NamedQueries({
	@NamedQuery(name="getUserDemand",query="from TbDemand d left join fetch d.tbUserByDemandClientId u where  d.tbUserByDemandUserId.userId=?"),
	@NamedQuery(name="getUserRequestDemand",query="from TbDemand d where d.tbUserByDemandClientId.userId=? "),
	@NamedQuery(name="getAllDemand",query=" from TbDemand d  left join fetch d.tbUserByDemandUserId order by d.demandStatus asc,d.demandTime desc"),
	@NamedQuery(name="getMySchoolDemand",query=" from TbDemand d  where d.tbUserByDemandUserId.userSchool like ? order by d.demandStatus asc,d.demandTime desc ")
	
})
/**
 * Entity: 
 */
@Entity
@Table(name = "tb_demand", catalog = "db_timeshop")
public class TbDemand implements java.io.Serializable {

	/** 
	 * ����id.
	 */

	private Integer demandId;

	/** 
	 * ������id.
	 */

	private TbUser tbUserByDemandClientId;

	/** 
	 * ���󷢲���.
	 */

	private TbUser tbUserByDemandUserId;

	/** 
	 * ��������.
	 */

	private String demandContent;

	/** 
	 * ��������0����ʱ�����Ǯ������1����ʱ����ʱ�佻��.
	 */

	private Integer demandType;

	/** 
	 * ����Ը�⸶���ļ۸������ʱ�����ͣ�����Ϊ����.
	 */

	private BigDecimal demandPay;

	/** 
	 * ����ͼƬ·�������ͼƬ��url��listתjson��ʽ.
	 */

	private String demandPhotoUrlJson;

	/** 
	 * ���޴���.
	 */

	private Integer demandLikeCount;

	/** 
	 * �������.
	 */

	private String demandTitle;

	/** 
	 * ���󷢲�ʱ��.
	 */

	private Date demandTime;

	/** 
	 * �������۴���.
	 */

	private Integer demandCommentCount;

	/** 
	 * ���󱻽���ʱ��.
	 */

	private Date demandAcceptTime;

	/** 
	 * �������ʱ��.
	 */

	private Date demandFinishTime;

	/** 
	 * ����ȡ��ʱ��.
	 */

	private Date demandCancelTime;

	/** 
	 * ����״̬.
	 */

	private Integer demandStatus;


	private Set<TbComment> tbComments = new HashSet<TbComment>(0);

	private Set<TbLike> tbLikes = new HashSet<TbLike>(0);

	private Set<TbLike> tbLikes_1 = new HashSet<TbLike>(0);

	private Set<TbComment> tbComments_1 = new HashSet<TbComment>(0);
	
	private Set<TbRequest> tbRequests= new HashSet<TbRequest>(0);
	public TbDemand() {
	}

	public TbDemand(TbUser tbUserByDemandUserId, boolean saidLike) {
		setTbUserByDemandUserId(tbUserByDemandUserId);

	}

	public TbDemand(TbUser tbUserByDemandClientId, TbUser tbUserByDemandUserId,
			String demandContent, Integer demandType, BigDecimal demandPay,
			String demandPhotoUrlJson, Integer demandLikeCount,
			String demandTitle, Date demandTime, Integer demandCommentCount,
			Date demandAcceptTime, Date demandFinishTime,
			Date demandCancelTime, Integer demandStatus,
			Set<TbComment> tbComments, Set<TbLike> tbLikes,
			Set<TbLike> tbLikes_1, Set<TbComment> tbComments_1,
			Set<TbRequest> tbRequest  ) {
		setTbUserByDemandClientId(tbUserByDemandClientId);
		setTbUserByDemandUserId(tbUserByDemandUserId);
		setDemandContent(demandContent);
		setDemandType(demandType);
		setDemandPay(demandPay);
		setDemandPhotoUrlJson(demandPhotoUrlJson);
		setDemandLikeCount(demandLikeCount);
		setDemandTitle(demandTitle);
		setDemandTime(demandTime);
		setDemandCommentCount(demandCommentCount);
		setDemandAcceptTime(demandAcceptTime);
		setDemandFinishTime(demandFinishTime);
		setDemandCancelTime(demandCancelTime);
		setDemandStatus(demandStatus);
		setTbComments(tbComments);
		setTbLikes(tbLikes);
		setTbLikes_1(tbLikes_1);
		setTbComments_1(tbComments_1);
		setTbRequests(tbRequest);
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "demand_id", unique = true, nullable = false)
	public Integer getDemandId() {
		return this.demandId;
	}

	public void setDemandId(Integer demandId) {
		this.demandId = demandId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "demand_client_id")
	public TbUser getTbUserByDemandClientId() {
		return this.tbUserByDemandClientId;
	}

	public void setTbUserByDemandClientId(TbUser tbUserByDemandClientId) {
		this.tbUserByDemandClientId = tbUserByDemandClientId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "demand_user_id", nullable = false)
	public TbUser getTbUserByDemandUserId() {
		return this.tbUserByDemandUserId;
	}

	public void setTbUserByDemandUserId(TbUser tbUserByDemandUserId) {
		this.tbUserByDemandUserId = tbUserByDemandUserId;
	}

	@Column(name = "demand_content", length = 600)
	public String getDemandContent() {
		return this.demandContent;
	}

	public void setDemandContent(String demandContent) {
		this.demandContent = demandContent;
	}

	@Column(name = "demand_type")
	public Integer getDemandType() {
		return this.demandType;
	}

	public void setDemandType(Integer demandType) {
		this.demandType = demandType;
	}

	@Column(name = "demand_pay", precision = 9)
	public BigDecimal getDemandPay() {
		return this.demandPay;
	}

	public void setDemandPay(BigDecimal demandPay) {
		this.demandPay = demandPay;
	}

	@Column(name = "demand_photo_url_json", length = 500)
	public String getDemandPhotoUrlJson() {
		return this.demandPhotoUrlJson;
	}

	public void setDemandPhotoUrlJson(String demandPhotoUrlJson) {
		this.demandPhotoUrlJson = demandPhotoUrlJson;
	}

	@Column(name = "demand_like_count")
	public Integer getDemandLikeCount() {
		return this.demandLikeCount;
	}

	public void setDemandLikeCount(Integer demandLikeCount) {
		this.demandLikeCount = demandLikeCount;
	}

	@Column(name = "demand_title", length = 20)
	public String getDemandTitle() {
		return this.demandTitle;
	}

	public void setDemandTitle(String demandTitle) {
		this.demandTitle = demandTitle;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "demand_time", length = 19)
	public Date getDemandTime() {
		return this.demandTime;
	}

	public void setDemandTime(Date demandTime) {
		this.demandTime = demandTime;
	}

	@Column(name = "demand_comment_count")
	public Integer getDemandCommentCount() {
		return this.demandCommentCount;
	}

	public void setDemandCommentCount(Integer demandCommentCount) {
		this.demandCommentCount = demandCommentCount;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "demand_accept_time", length = 19)
	public Date getDemandAcceptTime() {
		return this.demandAcceptTime;
	}

	public void setDemandAcceptTime(Date demandAcceptTime) {
		this.demandAcceptTime = demandAcceptTime;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "demand_finish_time", length = 19)
	public Date getDemandFinishTime() {
		return this.demandFinishTime;
	}

	public void setDemandFinishTime(Date demandFinishTime) {
		this.demandFinishTime = demandFinishTime;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "demand_cancel_time", length = 19)
	public Date getDemandCancelTime() {
		return this.demandCancelTime;
	}

	public void setDemandCancelTime(Date demandCancelTime) {
		this.demandCancelTime = demandCancelTime;
	}

	@Column(name = "demand_status")
	public Integer getDemandStatus() {
		return this.demandStatus;
	}

	public void setDemandStatus(Integer demandStatus) {
		this.demandStatus = demandStatus;
	}



	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tbDemand")
	public Set<TbComment> getTbComments() {
		return this.tbComments;
	}

	public void setTbComments(Set<TbComment> tbComments) {
		this.tbComments = tbComments;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tbDemand")
	@JSONField(serialize=false)
	public Set<TbLike> getTbLikes() {
		return this.tbLikes;
	}

	public void setTbLikes(Set<TbLike> tbLikes) {
		this.tbLikes = tbLikes;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tbDemand")
	@JSONField(serialize=false)
	public Set<TbLike> getTbLikes_1() {
		return this.tbLikes_1;
	}

	public void setTbLikes_1(Set<TbLike> tbLikes_1) {
		this.tbLikes_1 = tbLikes_1;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tbDemand")
	@JSONField(serialize=false)
	public Set<TbComment> getTbComments_1() {
		return this.tbComments_1;
	}

	public void setTbComments_1(Set<TbComment> tbComments_1) {
		this.tbComments_1 = tbComments_1;
	}
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tbDemand")
	@JSONField(serialize=false)
	public Set<TbRequest> getTbRequests() {
		return this.tbRequests;
	}

	public void setTbRequests(Set<TbRequest> tbRequests) {
		this.tbRequests = tbRequests;
	}

}
